home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / pdox693.zip / TI375.ASC < prev    next >
Text File  |  1993-03-18  |  5KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox                                NUMBER  :  375
  9.   VERSION  :  All
  10.        OS  :  DOS
  11.      DATE  :  March 18, 1993                           PAGE  :  1/3
  12.  
  13.     TITLE  :  Formatting Phone Number Fields
  14.  
  15.  
  16.  
  17.  
  18.   Sometimes it is necessary to manipulate alphanumeric data and
  19.   change its format.  One common example is data imported from a
  20.   mainframe.  Another example is data that has leading spaces.
  21.   This document demonstrates a PAL script that modifies the format
  22.   of data in a phone number field, containing 10 digits (for
  23.   example 4084399096), in one of the following three formats:
  24.   1) ###-###-####, 2) (###) ###-####, 3) (###)###-####.
  25.  
  26.   The script will divide the phone number field into three sections
  27.   1) characters 1 through 3 for the area code, 2) characters 4
  28.   through 6 for the prefix, and 3) characters 7 through 10 for the
  29.   suffix.  It  will reformat the phone number field according to
  30.   one of the formats described above by combining the three
  31.   sections with the appropriate string values (i.e. "(", ")", and
  32.   "-").  The script illustrates the PAL commands EDIT and SCAN, and
  33.   the PAL function SUBSTR().
  34.  
  35.   NOTE: Before making global changes to your table, it is a good
  36.         idea to first make a backup copy.
  37.  
  38.   Depending on the phone number format that you choose (1, 2 or 3
  39.   shown above), the phone number field will need to have a length
  40.   of 12, 13 or 14.  This will require restructuring your table.
  41.   For example, if you want to reformat the phone number field as
  42.   ###-###-####, and the data type of the Phone field is less than
  43.   of 12 characters, you will need to first Modify | Restructure
  44.   your table to increase the field length of the Phone field to 12
  45.   characters to accommodate the two hyphens before running the
  46.   script.  Please note that performing a Modify | Restructure and
  47.   changing the field length of your Phone field will remove the
  48.   Phone field from your existing Forms and Reports.  You will need
  49.   to modify your existing Forms and Reports to replace the Phone
  50.   field.
  51.  
  52.   Creating the script:
  53.  
  54.       o  From the Main menu, select Scripts | Editor | New (if you
  55.          are using version 3.5 or earlier, this will be Scripts |
  56.          Editor | Write).
  57.  
  58.       o  Type the name of the script (i.e. Phone) and press Enter.
  59.           
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox                                NUMBER  :  375
  75.   VERSION  :  All
  76.        OS  :  DOS
  77.      DATE  :  March 18, 1993                           PAGE  :  2/3
  78.  
  79.     TITLE  :  Formatting Phone Number Fields
  80.  
  81.  
  82.  
  83.  
  84.          You are now in the Script Editor.  Type the script that
  85.          appears below.  You will need to substitute your own table
  86.          name for "Tbl" and your own field name for "Phone".
  87.  
  88.           ; Here is the script
  89.  
  90.             COEDIT "Tbl"                    ;where Tbl is
  91.                                             ;  the table name
  92.             SCAN                            ;scans every record
  93.             a=SUBSTR([Phone], 1, 3)         ;variable assignment
  94.             b=SUBSTR([Phone], 4, 3)
  95.             c=SUBSTR([Phone], 7, 4)
  96.  
  97.                IF LEN([Phone])=10 THEN
  98.  
  99.             ;UNREMARK ONE OF THE OPTIONS BELOW BY REMOVING THE ";"
  100.  
  101.                ;[Phone]=a+"-"+b+"-"+c       ; ###-###-#### format
  102.                ;[Phone]="("+a+") "+b+"-"+c  ; (###) ###-#### format
  103.                ;[Phone]="("+a+")+b+"-"+c    ; (###)###-#### format
  104.  
  105.                ENDIF
  106.             ENDSCAN
  107.  
  108.           ; End of the script
  109.  
  110.             NOTE: The semicolon ";" indicates that a comment
  111.             follows and the information on that line will not be
  112.             executed when you play the script.  Depending on the
  113.             format that you choose, you will need to remove the ";"
  114.             that precedes that option.  For example, to format the
  115.             phone number field as ###-###-####, you will need to
  116.             remove the ";" that precedes the code:
  117.  
  118.             [Phone]=a+"-"+b+"-"+c       ; ###-###-#### format
  119.  
  120.       o  When you have finished typing the script, press F2 to save
  121.          the script.
  122.  
  123.   Playing the script:
  124.  
  125.       o  From the Main menu, select Scripts | Play, type the name
  126.          of your script (i.e. Phone), then press Enter.
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox                                NUMBER  :  375
  141.   VERSION  :  All
  142.        OS  :  DOS
  143.      DATE  :  March 18, 1993                           PAGE  :  3/3
  144.  
  145.     TITLE  :  Formatting Phone Number Fields
  146.  
  147.  
  148.  
  149.  
  150.           
  151.          Paradox will modify every record in your table and
  152.          separate the area code, the prefix, and suffix with
  153.          hyphens.  When the script is finished you will still be in
  154.          Coedit mode.  To save the table, press F2.
  155.  
  156.  
  157.   For additional reference on these and other PAL commands and
  158.   functions, refer to the PAL Reference Guide (for versions earlier
  159.   than 4.0, refer to the PAL User's Guide).
  160.  
  161.  
  162.   DISCLAIMER: You have the right to use this technical information
  163.   subject to the terms of the No-Nonsense License Statement that
  164.   you received with the Borland product to which this information
  165.   pertains.
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.